<?php

namespace app\common\validate\tyyh;

class UserAddress extends Base
{
	/**
     * 验证规则
     */
    protected $rule = [
        'lock'                => 'require',
        'id'                  => 'require',
        'ids'                 => 'require|isUsers:tyyh\\UserAddress',
        'uid'                 => 'require',
        'name'                => 'require|max:32',
        'sex'                 => 'require|isOptions:Sex',
        'house_number'        => 'require|max:32',
        'mobile'              => 'require|regex:/^1[1-9]\d{9}$/',
        'address'             => 'require|max:100'
    ];


    /**
     * 提示消息
     */
    protected $message = [
        'lock.require'                  => '验证规则场景不存在',
        'id.require'                    => '地址ID不能为空',
        'uid.require'                   => '用户ID不能为空',
        'name.require'                  => '联系人不能为空',
        'name.max'                      => '联系人不能超过32个字符',
        'sex.require'                   => '性别不能为空',
        'sex.isOptions'                 => '性别不合法',
        'house_number.require'          => '门牌号不能为空',
        'house_number.max'              => '门牌号不能超过32个字符',
        'mobile.require'                => '手机不能为空',
        'mobile.regex'                  => '手机号不合法',
        'address.require'               => '地址不能为空',
        'address.max'                   => '地址不能超过100个字符'
    ];
    /**
     * 验证场景
     */
    protected $scene = [
        'save'        => [
            'id' => 'isUser:tyyh\\UserAddress',
            'uid',
            'name',
            'mobile',
            'address'
        ],
        'private'     => ['uid'],
        'info'        => ['id' => 'isUser:tyyh\\UserAddress'],
        'del'         => ['id' => 'isUser:tyyh\\UserAddress'],
        'dels'        => ['ids']
    ];
}
